<template>
	<view class="goods-item">
		<!-- 商品左侧图片区域 -->
		<view class="goods-item-left">
			<image class="goods-image" :src="goods.goods_small_logo || defaultPic"></image>
		</view>
		<!-- 商品右侧信息区域 -->
		<view class="goods-item-right">
			<!-- 商品标题 -->
			<view class="goods-name">{{goods.goods_name}}</view>
			<!-- 商品价格 -->
			<view class="goods-price">{{goods.goods_price | tofixed | appendYuan }}</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "my-goods",
		data() {
			return {
				// 图片不存在的默认替代图片
				defaultPic: 'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-medium.png'
			};
		},
		props: {
			// 要渲染的商品数据
			goods: {
				type: Object,
				default: {}
			}
		},

		filters: {
			tofixed(num) {
				return Number(num).toFixed(2)
			},
			appendYuan(arg) {
				return '¥' + arg
			}
		}


	}
</script>

<style lang="scss">
	.goods-item {
		display: flex;
		border-bottom: 1px solid #efefef;
		padding: 8rpx;

		.goods-item-left {
			.goods-image {
				width: 200rpx;
				height: 200rpx;
				vertical-align: middle;
			}
		}

		.goods-item-right {
			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.goods-name {
				font-size: 24rpx;
			}

			.goods-price {
				font-size: 32rpx;
				color: #c00000;
			}
		}
	}
</style>
